#ifndef ZAUTOUPDATE_H
#define ZAUTOUPDATE_H

#include <QtGui/QWidget>
#include "ui_zautoupdate.h"
#include <QThread>
#include <Windows.h>

class ZAutoUpdateWidget : public QWidget
{
	Q_OBJECT

public:
	ZAutoUpdateWidget(QWidget *parent = 0, Qt::WFlags flags = 0);
	~ZAutoUpdateWidget();

public:
	void SetCurrentState(QString sShowMsg, bool bExit, bool bUpdateSuccess=false);

signals:
	void currentStateChangeSignal(QString sShowMsg, bool bExit, bool bUpdateSuccess);

private slots:
	void onCurrentStateChange(QString sShowMsg, bool bExit, bool bUpdateSuccess);

private:
	Ui::ZAutoUpdateClass ui;
};

class ZUpdateThread : public QThread
{
//#define UpdateCfgFile "http://27.221.23.34/download/updatecfg.txt"
#define UpdateCfgFile "http://www.wuliumeng.com/download/updatecfg.txt"
public:
	ZUpdateThread(ZAutoUpdateWidget* pWidget);

public:
	virtual void run();

private:
	bool _dealCmd(const QString& sCmd);

	DWORD _processToPID(const char *pszProcessName);

private:
	ZAutoUpdateWidget*		m_pWidget;
};

#endif // ZAUTOUPDATE_H
